package com.patelski.magic.model;

// Generated 16-mei-2008 9:57:53 by Hibernate Tools 3.2.0.b10

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Transient;

import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.hibernate.validator.NotNull;

/**
 * Inventory generated by hbm2java
 */
@Entity
@Table(name = "INVENTORY", catalog = "mtginventory")
@NamedQueries( { @NamedQuery(name = "cardInInventory", query = "SELECT inventory FROM Inventory inventory WHERE inventory.card = :card and inventory.user = :user") })
public class Inventory implements java.io.Serializable {

	private Integer id;
	private User user;
	private Card card;
	private int have;
	private int keep;
	private BigDecimal buyAmount = new BigDecimal(0.00);
	private BigDecimal sellAmount = new BigDecimal(0.00);
	private BigDecimal totalAmount = new BigDecimal(0.00);
	private String note;

	public Inventory() {
	}

	public Inventory(User user, Card card, int have, int keep,
			BigDecimal buyAmount, BigDecimal sellAmount, BigDecimal totalAmount) {
		this.user = user;
		this.card = card;
		this.have = have;
		this.keep = keep;
		this.buyAmount = buyAmount;
		this.sellAmount = sellAmount;
		this.totalAmount = totalAmount;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "ID", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "USER_ID", nullable = false)
	@NotNull
	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "CARD_ID", nullable = false)
	@NotNull
	public Card getCard() {
		return this.card;
	}

	public void setCard(Card card) {
		this.card = card;
	}

	@Column(name = "HAVE", nullable = false)
	@NotNull
	public int getHave() {
		return this.have;
	}

	public void setHave(int have) {
		this.have = have;
	}

	@Column(name = "KEEP", nullable = false)
	@NotNull
	public int getKeep() {
		return this.keep;
	}

	public void setKeep(int keep) {
		this.keep = keep;
	}

	@Column(name = "BUY_AMOUNT", nullable = false, columnDefinition = "decimal(8,2)")
	@NotNull
	public BigDecimal getBuyAmount() {
		return this.buyAmount;
	}

	public void setBuyAmount(BigDecimal buyAmount) {
		this.buyAmount = buyAmount;
	}

	@Column(name = "SELL_AMOUNT", nullable = false, columnDefinition = "decimal(8,2)")
	@NotNull
	public BigDecimal getSellAmount() {
		return this.sellAmount;
	}

	public void setSellAmount(BigDecimal sellAmount) {
		this.sellAmount = sellAmount;
	}

	@Column(name = "TOTAL_AMOUNT", nullable = false, columnDefinition = "decimal(8,2)")
	@NotNull
	public BigDecimal getTotalAmount() {
		return this.totalAmount;
	}

	public void setTotalAmount(BigDecimal totalAmount) {
		this.totalAmount = totalAmount;
	}

	@Column(name = "NOTE", columnDefinition = "text")
	public String getNote() {
		return note;
	}

	public void setNote(String note) {
		this.note = note;
	}

	@Transient
	public int getForTrade() {
		return (this.getHave() - this.getKeep()) >= 0 ? (this.getHave() - this
				.getKeep()) : 0;
	}

	public void setForTrade(int forTrade) {
	}

	@Transient
	public int getWanted() {
		return (this.getKeep() - this.getHave()) >= 0 ? (this.getKeep() - this
				.getHave()) : 0;
	}

	public void setWanted(int wanted) {
	}

}
